<?php require_once('Connections/myconnect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "login")) {
  $insertSQL = sprintf("INSERT INTO thanhvien (TenDN, MatKhau, HoTen, Gioitinh, NgaySinh, Email) VALUES (%s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['username'], "text"),
                       GetSQLValueString($_POST['password'], "text"),
                       GetSQLValueString($_POST['name'], "text"),
                       GetSQLValueString(isset($_POST['jumpMenu']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString($_POST['birthday'], "date"),
                       GetSQLValueString($_POST['email'], "text"));

  mysql_select_db($database_myconnect, $myconnect);
  $Result1 = mysql_query($insertSQL, $myconnect) or die(mysql_error());

  $insertGoTo = "Dangnhap.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dang Ki Thanh Vien</title>
<link rel="stylesheet" type="text/css" href="CSS/style.css">
<style type="text/css">
<!--
.style1 {
	font-size: 20px;
	font-weight: bold;
	color: #333333;
}
.style2 {
	color: #00aeef;
	font-size: 17px;
	font-weight: bold;
}
.loginform {
	width: 300px;
}
.style3 {font-family: Arial, Helvetica, sans-serif}
.style4 {
	font-size: 13px;
	font-weight: bold;
	text-align:right;
}
.style10 {font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: bold; }
.style12 {font-size: 14px}
.style13 {
	color: #008ec4;
	font-weight: bold;
}
.btnlogin {
	background-image: url(images/login_button_backgroun.gif);
	background-repeat: repeat-x;
	height: 23px;
	width: 65px;
	border: thin solid #007ebf;
	color: #FFFFFF;
	font-weight: bold;
}
.fontlogin {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	color: #000000;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>

<body>
<div id="wrapper"><span class="style1"> &nbsp;&nbsp; Đăng kí thành viên</span><br/>
    <hr width=90% color="#999999"  />
    
  <form action="<?php echo $editFormAction; ?>" id="login" name="login" method="POST">
      
    <p class="style2"><br/>&nbsp;&nbsp;Chọn tên đăng nhập và mật khẩu</p>
    <div id="login01">
    <br/>
      <table width="90%" border="0" align="right">
        <tr>
          <td width="30%"><span class="style4"><span class="fontlogin">Tên đăng nhập</span>:</span></td>
          <td width="300">
            <label>
              <input name="username" type="text" class="loginform" id="username" />
            </label>          </td>
        </tr>
        <tr>
          <td width="30%"><span class="fontlogin">Mật khẩu:</span></td>
          <td width="300">
            <label>
              <input name="password" type="password" class="loginform" id="password" />
            </label>          </td>
        </tr>
        <tr>
          <td width="30%"><span class="fontlogin">Nhập lại mật khẩu:</span></td>
          <td width="300">
            <input name="repassword" type="password" class="loginform" id="repassword" />          </td>
        </tr>
      </table>
    </div>
    <p class="style2">&nbsp;&nbsp;Điền thông tin cá nhân </p>
    <div id="login02">
      <br/>
      <table width="90%" border="0" align="right">
        <tr>
          <td width="30%" class="fontlogin">Họ và Tên: </td>
          <td width="300">
            <label>
              <input name="name" type="text" class="loginform" id="name" />
            </label>          </td>
        </tr>
        <tr>
          <td width="30%" class="fontlogin"><span class="fontlogin">Email:</span></td>
          <td width="300">
            <label>
              <input name="email" type="text" class="loginform" id="email" />
            </label>          </td>
        </tr>
        <tr>
          <td width="30%" class="fontlogin">Giới tính:</td>
          <td width="300"><select name="jumpMenu" class="loginform" id="jumpMenu"">
            <option value="2">Chọn giới tính...</option>
            <option value="1">Nam</option>
            <option value="0">Nữ</option>
                    </select></td>
        </tr>
        <tr>
          <td class="fontlogin">Ngày sinh:</td>
          <td><input name="birthday" type="text" class="loginform" id="birthday" /></td>
        </tr>
      </table>
      <p>&nbsp;</p>
    </div>
    <label>
    <div id="footerlogin" style="text-align:center">
      <p>
        <input type="checkbox" name="ckAgree" id="ckAgree" />
        </label>
      <span class="style12">Tôi đã đọc kĩ và hoàn toàn đồng ý với <span class="style13">Những điều khoản sử dụng</span></span></p>
      <p>
        <label>
        <input name="submit" type="submit" class="btnlogin" id="submit" value="Đăng kí" /> 
        </label>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <label>
        <input name="reset" type="reset" class="btnlogin" id="reset" value="Nhập lại" />
        </label>
        <br/>
        </p>
    </div>
    
    
    
    <input type="hidden" name="MM_insert" value="login" />
  </form>
  <p>&nbsp;</p>
</div>
</body>


</html>
